﻿using Ewell.BizComponent.UI.Charge.ViewModel;
using Ewell.Interface.Common.Model.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Ewell.BizComponent.UI.Charge.Views
{
    /// <summary>
    /// PreCashierView.xaml 的交互逻辑
    /// </summary>
    public partial class PreSettlementView : UserControl
    {
        public static readonly DependencyProperty PreCashierVmProperty = DependencyProperty
            .Register("preSettlementVm", typeof(PreSettlementVm), typeof(PreSettlementView),
            new FrameworkPropertyMetadata(new PreSettlementVm()));
        public PreSettlementVm preSettlementVm {
            get
            {
                if (this.DataContext?.GetType() != typeof(PreSettlementVm))
                    return (PreSettlementVm)GetValue(PreCashierVmProperty);
                else
                    return this.DataContext as PreSettlementVm;
            }
            set { SetValue(PreCashierVmProperty, value); }
        }
        public PreSettlementView()
        {
            InitializeComponent();
        }
        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            if (preSettlementVm == null)
                throw new SpeedException("HISBIZ", "缺少预算数据！");
            if (preSettlementVm.searchItemComVm == null)
            {
                preSettlementVm.searchItemComVm = new SearchItemCom.ViewModel.SearchItemComVm();
                preSettlementVm.searchItemComVm.selectedPatientType = preSettlementVm.selectedPatientType;
            }
            if (preSettlementVm.searchPersonComVm==null)
                preSettlementVm.searchPersonComVm=new SearchPersonCom.ViewModel.SearchPersonComVm();
            this.DataContext = preSettlementVm;
        }
    }
}
